<template>
  <div class="news-info">
    <!-- 新闻内容 -->
    <div class="mui-card content" v-if="info">
      <div class="mui-card-header" style="text-align:center">
        <h3>{{ info.title }}</h3>
        <p>
          <span>发表时间：{{info.add_time | dateFormat}}</span>
          &nbsp;&nbsp;&nbsp;&nbsp;
          <span>点击：{{info.click}}次</span>
        </p>
      </div>
      <div class="mui-card-content">
        <div class="mui-card-content-inner" v-html="info.content"></div>
      </div>
    </div>
    <!-- 评论列表 -->
    <comment :newId="id"></comment>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
import comment from "../subcomponent/Comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.id,
      info: null
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("api/getnew/" + this.id).then(rs => {
        let data = rs.body;
        if (data.status === 0) {
          this.info = data.message[0];
          Toast("新闻数据获取成功");
        } else {
          Toast("新闻数据获取失败");
        }
      });
    }
  },
  components: {
    comment
  }
};
</script>


<style lang="scss" scoped>
.news-info {
  .content {
    margin: 5px;
    .mui-card-header {
      padding: 0;
      display: block;
      justify-content: none;
      h3 {
        width: 100%;
        text-align: center;
        font-weight: 400;
        font-size: 16px;
        color: #0588ec;
        margin: 10px 0px;
      }
      p {
        color: #5aabef;
        font-size: 12px;
      }
    }
  }

  .comment {
    margin: 10px 5px;
    .mui-card-header {
      font-size: 14px;
    }
    .mui-card-content {
      #textarea {
        height: 100px;
        font-size: 12px;
      }
    }
  }
}
</style>